@extends('admin.main')

@section('body')
    <!-- 标题栏 -->
    <div class="main-title">
        <h2>水桶记录</h2>
    </div>
    <div class="cf">
        <div class="fl">
            <a class="btn" href="{{urlPlat('single','getBucketDataAdd')}}">新 增</a>
        </div>
    </div>
    <!-- 数据列表 -->
    <div class="data-table table-striped">
        <table class="">
            <thead>
            <tr>
                <th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>
                {{--<th class="">ID</th>--}}
                <th class="">店铺名</th>
                <th class="">水桶品牌</th>
                {{--<th class="">店内水桶</th>--}}
                <th class="">店外水桶</th>
                {{--<th class="">水桶总计</th>--}}
                {{--<th class="">创建时间</th>--}}
                {{--<th class="">更新时间</th>--}}
                <th class="">操作</th>
            </tr>
            </thead>
            <tbody>
            @if(count($category))
                @foreach($category as $v)
                    <tr>
                        <td><input class="ids" type="checkbox" name="ids[]" value="{{$v['id']}}"/></td>
                        <td>{{isset($shop) && count($shop) ? $shop['shop_name'] : ''}}</td>
                        <td>
                            <a href="{{urlPlat('single','getBucketDataLog',['bucket_category_id'=>$v['id'],'shop_id'=>$shop['id'],'title'=>$v['title']])}}">{{$v['title']}}</a>
                        </td>
                        <td>{{$v['bucket_num_out']}}</td>
                        <td>
                            <a href="javascript:;" onclick="showInfo({{$v['id']}})">详情</a>
                        </td>
                    </tr>
                @endforeach
            @else
                <td colspan="12" class="text-center"> aOh! 暂时还没有内容!</td>
            @endif
            </tbody>
        </table>
    </div>
@endsection

@section('script')

    <script type="text/javascript">

        //搜索功能
        $("#search").click(function(){
            var url = $(this).attr('url');
            var shop_id = $("#sch-sort-txt").attr("data");
            var query  = $('.search-form').find('input').serialize();
            query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
            query = query.replace(/^&/g,'');
            if(shop_id != ''){
                query = 'shop_id=' + shop_id + "&" + query;
            }
            if( url.indexOf('?')>0 ){
                url += '&' + query;
            }else{
                url += '?' + query;
            }
            window.location.href = url;
        });

        /* 状态搜索子菜单 */
        $(".search-form").find(".drop-down").hover(function(){
            $("#sub-sch-menu").removeClass("hidden");
        },function(){
            $("#sub-sch-menu").addClass("hidden");
        });
        $("#sub-sch-menu li").find("a").each(function(){
            $(this).click(function(){
                var text = $(this).text();
                $("#sch-sort-txt").text(text).attr("data",$(this).attr("value"));
                $("#sub-sch-menu").addClass("hidden");
                var shop_id = $(this).attr("value");
                window.location.href = '{{urlPlat('single','getBucketData')}}?shop_id='+shop_id;
            })
        });
    </script>
@endsection
